home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-12 | 9.8 KB | 285 lines | [TEXT/PJMM] |
- unit Components;
-
- { Pascal Interface to the Macintosh Libraries }
-
- { Copyright © Apple Computer Inc. }
- { All Rights Reserved }
-
- { Adapted for use with THINK Pascal 4.0.x by Marco Piovanelli }
-
- interface
- uses
- Types;
-
- const
-
- { gestalt constants (!!! transplanted from GestaltEqu.p !!!) }
- gestaltComponentMgr = 'cpnt';
-
- { Component Manager & component errors (!!! transplanted from Errors.p !!!) }
- invalidComponentID = -3000;
- validInstancesExist = -3001;
- componentNotCaptured = -3002;
- componentDontRegister = -3003;
-
- kAppleManufacturer = 'appl'; { Apple supplied components }
- kComponentResourceType = 'thng';
-
- kAnyComponentType = 0;
- kAnyComponentSubType = 0;
- kAnyComponentManufacturer = 0;
- kAnyComponentFlagsMask = 0;
-
- cmpWantsRegisterMessage = $80000000;
-
- kComponentOpenSelect = -1; { ComponentInstance for this open }
- kComponentCloseSelect = -2; { ComponentInstance for this close }
- kComponentCanDoSelect = -3; { selector # being queried }
- kComponentVersionSelect = -4; { no params }
- kComponentRegisterSelect = -5; { no params }
- kComponentTargetSelect = -6; { ComponentInstance for top of call chain }
- kComponentUnregisterSelect = -7; { no params }
-
- { Component Resource Extension flags }
- componentDoAutoVersion = $00000001;
- componentWantsUnregister = $00000002;
- componentAutoVersionIncludeFlags = $00000004;
- componentHasMultiplePlatforms = $00000008;
-
- { Set Default Component flags }
- defaultComponentIdentical = 0;
- defaultComponentAnyFlags = 1;
- defaultComponentAnyManufacturer = 2;
- defaultComponentAnySubType = 4;
- defaultComponentAnyFlagsAnyManufacturer = 0 + (defaultComponentAnyFlags + defaultComponentAnyManufacturer);
- defaultComponentAnyFlagsAnyManufacturerAnySubType = 0 + (defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType);
-
- { RegisterComponentResource flags }
- registerComponentGlobal = 1;
- registerComponentNoDuplicates = 2;
- registerComponentAfterExisting = 4;
-
-
- type
- ComponentDescription = record
- componentType: OSType; { A unique 4-byte code indentifying the command set }
- componentSubType: OSType; { Particular flavor of this instance }
- componentManufacturer: OSType; { Vendor indentification }
- componentFlags: LONGINT; { 8 each for Component,Type,SubType,Manuf/revision }
- componentFlagsMask: LONGINT; { Mask for specifying which flags to consider in search, zero during registration }
- end;
- ResourceSpec = record
- resType: OSType; { 4-byte code }
- resID: INTEGER;
- end;
- ComponentResource = record
- cd: ComponentDescription; { Registration parameters }
- component: ResourceSpec; { resource where Component code is found }
- componentName: ResourceSpec; { name string resource }
- componentInfo: ResourceSpec; { info string resource }
- componentIcon: ResourceSpec; { icon resource }
- end;
- ComponentResourcePtr = ^ComponentResource;
- ComponentResourceHandle = ^ComponentResourcePtr;
-
- ComponentPlatformInfo = record
- componentFlags: LONGINT; { flags of Component }
- component: ResourceSpec; { resource where Component code is found }
- platformType: INTEGER; { gestaltSysArchitecture result }
- end;
- ComponentResourceExtension = record
- componentVersion: LONGINT; { version of Component }
- componentRegisterFlags: LONGINT; { flags for registration }
- componentIconFamily: INTEGER; { resource id of Icon Family }
- end;
- ComponentPlatformInfoArray = record
- count: LONGINT;
- platformArray: array[0..0] of ComponentPlatformInfo;
- end;
- ExtComponentResource = record
- cd: ComponentDescription; { registration parameters }
- component: ResourceSpec; { resource where Component code is found }
- componentName: ResourceSpec; { name string resource }
- componentInfo: ResourceSpec; { info string resource }
- componentIcon: ResourceSpec; { icon resource }
- componentVersion: LONGINT; { version of Component }
- componentRegisterFlags: LONGINT; { flags for registration }
- componentIconFamily: INTEGER; { resource id of Icon Family }
- count: LONGINT; { elements in platformArray }
- platformArray: array[0..0] of ComponentPlatformInfo;
- end;
- ComponentParameters = packed record
- flags: CHAR; { call modifiers: sync/async, deferred, immed, etc }
- paramSize: CHAR; { size in bytes of actual parameters passed to this call }
- what: INTEGER; { routine selector, negative for Component management calls }
- params: array[0..0] of LONGINT; { actual parameters for the indicated routine }
- end;
- ComponentRecord = record
- data: array[0..0] of LONGINT;
- end;
- Component = ^ComponentRecord;
-
- ComponentInstanceRecord = record
- data: array[0..0] of LONGINT;
- end;
- ComponentInstance = ^ComponentInstanceRecord;
-
- ComponentResult = LONGINT;
-
- ComponentRoutineProcPtr = ProcPtr; { FUNCTION ComponentRoutine(VAR cp: ComponentParameters; componentStorage: Handle): ComponentResult; }
- ComponentRoutineUPP = UniversalProcPtr;
-
- const
- uppComponentRoutineProcInfo = $000003F0; { FUNCTION (4 byte param, 4 byte param): 4 byte result; }
-
- function NewComponentRoutineProc (userRoutine: ComponentRoutineProcPtr): ComponentRoutineUPP;
- inline
- $2E9F;
-
- function CallComponentRoutineProc (var cp: ComponentParameters;
- componentStorage: Handle;
- userRoutine: ComponentRoutineUPP): ComponentResult;
- inline
- $205F, $4E90;
-
- type
- ComponentRoutine = ComponentRoutineUPP;
-
- {}
- { The parameter list for each ComponentFunction is unique. It is }
- { therefore up to users to create the appropriate procInfo for their }
- { own ComponentFunctions where necessary.}
- {}
- ComponentFunctionUPP = UniversalProcPtr;
-
-
- function RegisterComponent (var cd: ComponentDescription;
- componentEntryPoint: ComponentRoutineUPP;
- global: INTEGER;
- componentName: Handle;
- componentInfo: Handle;
- componentIcon: Handle): Component;
- inline
- $7001, $A82A;
- function RegisterComponentResource (tr: ComponentResourceHandle;
- global: INTEGER): Component;
- inline
- $7012, $A82A;
- function UnregisterComponent (aComponent: Component): OSErr;
- inline
- $7002, $A82A;
- function FindNextComponent (aComponent: Component;
- var looking: ComponentDescription): Component;
- inline
- $7004, $A82A;
- function CountComponents (var looking: ComponentDescription): LONGINT;
- inline
- $7003, $A82A;
- function GetComponentInfo (aComponent: Component;
- var cd: ComponentDescription;
- componentName: Handle;
- componentInfo: Handle;
- componentIcon: Handle): OSErr;
- inline
- $7005, $A82A;
- function GetComponentListModSeed: LONGINT;
- inline
- $7006, $A82A;
- { Component Instance Allocation and dispatch routines }
- function OpenComponent (aComponent: Component): ComponentInstance;
- inline
- $7007, $A82A;
- function CloseComponent (aComponentInstance: ComponentInstance): OSErr;
- inline
- $7008, $A82A;
- function GetComponentInstanceError (aComponentInstance: ComponentInstance): OSErr;
- inline
- $700A, $A82A;
- { Direct calls to the Components }
- function ComponentFunctionImplemented (ci: ComponentInstance;
- ftnNumber: INTEGER): LONGINT;
- inline
- $2F3C, $2, $FFFD, $7000, $A82A;
- function GetComponentVersion (ci: ComponentInstance): LONGINT;
- inline
- $2F3C, $0, $FFFC, $7000, $A82A;
- function ComponentSetTarget (ci: ComponentInstance;
- target: ComponentInstance): LONGINT;
- inline
- $2F3C, $4, $FFFA, $7000, $A82A;
- { Component Management routines }
- procedure SetComponentInstanceError (aComponentInstance: ComponentInstance;
- theError: OSErr);
- inline
- $700B, $A82A;
- function GetComponentRefcon (aComponent: Component): LONGINT;
- inline
- $7010, $A82A;
- procedure SetComponentRefcon (aComponent: Component;
- theRefcon: LONGINT);
- inline
- $7011, $A82A;
- function OpenComponentResFile (aComponent: Component): INTEGER;
- inline
- $7015, $A82A;
- function CloseComponentResFile (refnum: INTEGER): OSErr;
- inline
- $7018, $A82A;
- { Component Instance Management routines }
- function GetComponentInstanceStorage (aComponentInstance: ComponentInstance): Handle;
- inline
- $700C, $A82A;
- procedure SetComponentInstanceStorage (aComponentInstance: ComponentInstance;
- theStorage: Handle);
- inline
- $700D, $A82A;
- function GetComponentInstanceA5 (aComponentInstance: ComponentInstance): LONGINT;
- inline
- $700E, $A82A;
- procedure SetComponentInstanceA5 (aComponentInstance: ComponentInstance;
- theA5: LONGINT);
- inline
- $700F, $A82A;
- function CountComponentInstances (aComponent: Component): LONGINT;
- inline
- $7013, $A82A;
- { Useful helper routines for convenient method dispatching }
- function CallComponentFunction (var params: ComponentParameters;
- func: ComponentFunctionUPP): LONGINT;
- inline
- $70FF, $A82A;
- function CallComponentFunctionWithStorage (storage: Handle;
- var params: ComponentParameters;
- func: ComponentFunctionUPP): LONGINT;
- inline
- $70FF, $A82A;
- function DelegateComponentCall (var originalParams: ComponentParameters;
- ci: ComponentInstance): LONGINT;
- inline
- $7024, $A82A;
- function SetDefaultComponent (aComponent: Component;
- flags: INTEGER): OSErr;
- inline
- $701E, $A82A;
- function OpenDefaultComponent (componentType: OSType;
- componentSubType: OSType): ComponentInstance;
- inline
- $7021, $A82A;
- function CaptureComponent (capturedComponent: Component;
- capturingComponent: Component): Component;
- inline
- $701C, $A82A;
- function UncaptureComponent (aComponent: Component): OSErr;
- inline
- $701D, $A82A;
- function RegisterComponentResourceFile (resRefNum: INTEGER;
- global: INTEGER): LONGINT;
- inline
- $7014, $A82A;
- function GetComponentIconSuite (aComponent: Component;
- var iconSuite: Handle): OSErr;
- inline
- $7029, $A82A;
-
- implementation
- end.